import { DatabaseTypes } from '../../models/databaseTypes'
import { Db2Provider } from '../db2/db2Provider'
import { MariaDbImportProvider } from '../mariadb/mariaDbImportProvider'
import { MariaDbProvider } from '../mariadb/mariaDbProvider'
import { MsSqlProvider } from '../mssql/msSqlProvider'
import { MySqlProvider } from '../mysql/mySqlProvider'
import { OracleProvider } from '../oracle/oracleProvider'
import { PostgreSqlProvider } from '../postgresql/postgreSqlProvider'
import { SqliteProvider } from '../sqlite/sqliteSqlProvider'
import { DbImportProvider } from './dbImportProvider'
import { DbProvider } from './dbProvider'

export class ProviderFactory {
	public static getProvider(providerName: DatabaseTypes): DbProvider {
		if (providerName === DatabaseTypes.db2) {
			return new Db2Provider()
		}
		if (providerName === DatabaseTypes.mariadb) {
			return new MariaDbProvider()
		}
		if (providerName === DatabaseTypes.mssql) {
			return new MsSqlProvider()
		}
		if (providerName === DatabaseTypes.mysql) {
			return new MySqlProvider()
		}
		if (providerName === DatabaseTypes.oracle) {
			return new OracleProvider()
		}
		if (providerName === DatabaseTypes.postgresql) {
			return new PostgreSqlProvider()
		}
		if (providerName === DatabaseTypes.sqlite) {
			return new SqliteProvider()
		}
		return new OracleProvider()
	}

	public static getImportProvider(providerName: DatabaseTypes): DbImportProvider {
		if (providerName === DatabaseTypes.db2) {
			throw new Error(`${providerName} is not implemented`)
		}
		if (providerName === DatabaseTypes.mariadb) {
			return new MariaDbImportProvider()
		}
		if (providerName === DatabaseTypes.mssql) {
			throw new Error(`${providerName} is not implemented`)
		}
		if (providerName === DatabaseTypes.mysql) {
			return new MariaDbImportProvider()
		}
		if (providerName === DatabaseTypes.oracle) {
			throw new Error(`${providerName} is not implemented`)
		}
		if (providerName === DatabaseTypes.postgresql) {
			throw new Error(`${providerName} is not implemented`)
		}
		if (providerName === DatabaseTypes.sqlite) {
			throw new Error(`${providerName} is not implemented`)
		}
		throw new Error(`${providerName} is not implemented`)
	}
}
